﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Index.aspx.cs" Inherits="Companys_Index" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link href="../css/Site.css" rel="stylesheet" type="text/css" />
    <link href="../css/smoothness/jquery-ui-1.8.2.custom.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <form id="form1" runat="server">
    <div style="padding: 4px;">
        <asp:Button style="margin-left: 5px;" ID="btnCreate" runat="server" Text="添加公司" OnClick="btnCreate_Click" /> 
        <input style="margin-left: 5px;" id="setLeader" runat =server  type="button" value="设置组安全员"  /> 
          <asp:Button style="margin-left: 5px;" ID="btnImport" runat="server" Text="导入Excel" OnClick="btnImport_Click" />
        <asp:FileUpload style="margin-left: 5px;" ID="fuImport" runat="server" />
    </div>
    <div>
        <asp:GridView ID="gvCompanys" runat="server" AutoGenerateColumns="False" CellPadding="4"
            DataKeyNames="CompanyID" ForeColor="#333333" GridLines="None" AllowPaging="True"
            Style="width: 100%; text-align:center;" PageSize="10" 
            OnPageIndexChanging="gvCompanys_PageIndexChanging" EmptyDataText="暂时没有数据"
            OnRowCommand="gvCompanys_RowCommand" OnRowDeleting="gvUsers_RowDeleting" onrowediting="gvCompanys_RowEditing" 
            >
            <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
            <Columns>
                <asp:TemplateField>
                    <HeaderTemplate>
                        选择
                    </HeaderTemplate>
                    <ItemTemplate>
                        <asp:CheckBox ID="CheckItem" runat="server" />
                        
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="CompanyID" HeaderText="CompanyID" InsertVisible="False"
                    ReadOnly="True" SortExpression="CompanyID" Visible="False" />
                <asp:BoundField DataField="CompanyName" HeaderText="公司名称" SortExpression="CompanyName" />
                <asp:BoundField DataField="Address" HeaderText="地址" SortExpression="Address" />
                <asp:BoundField DataField="Contact" HeaderText="联系方式" SortExpression="Contact" />
                <asp:BoundField DataField="ContactPerson" HeaderText="联系人" SortExpression="ContactPerson" />
                <asp:BoundField DataField="Phone" HeaderText="电话" SortExpression="Phone" />
                <asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" />
                <asp:BoundField DataField="CurrentIntegral" HeaderText="当前剩下积分" SortExpression="CurrentIntegral" />
                <asp:TemplateField HeaderText="是否自动重置" SortExpression="IsAutoRecharge">
                    <ItemTemplate>
                        <%# (Convert.ToInt32(Eval("IsAutoRecharge")) == 1 ? "是" : "否")%>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="GuardLine" HeaderText="警戒线" SortExpression="GuardLine" />
                <asp:TemplateField HeaderText="是否超出警戒线" SortExpression="">
                    <ItemTemplate>
                        <%# (Convert.ToInt32(Eval("GuardLine") )>= Convert.ToInt32(Eval("CurrentIntegral") ) ? "是" : "否")%>
                    </ItemTemplate>
                </asp:TemplateField>

                <asp:CommandField HeaderText="操作" ShowDeleteButton="True" ShowEditButton="True" ShowHeader="True" />
                <asp:TemplateField HeaderText="操作">
                    <ItemTemplate>
                        <asp:LinkButton ID="btnUserList" runat="server" CommandName="UserList" CommandArgument='<%#Eval("CompanyID") %>'
                            Text="查看人员列表" />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField ShowHeader=false>
                   
                    <ItemTemplate>
                       
                        <asp:HiddenField ID="hCompanyID" runat="server" Value='<%# Eval("CompanyID") %> ' />
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
            <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
            <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
            <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
            <EditRowStyle BackColor="#999999" />
            <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
        </asp:GridView>
    </div>
    <div id="leaderpanel" title="请选择要进行管理的组安全员" style="display:none;">
        <p>
            请选择要进行管理的组安全员：
            <asp:DropDownList ID="ddlleader" runat="server">
            </asp:DropDownList>
             <asp:Button ID="BtnSetLeader" runat="server" Text="设置" 
            onclick="BtnSetLeader_Click" />
        </p>
    </div>
    </form>
</body>
<script src="../script/jquery-1.4.2.min.js" type="text/javascript"></script>
<script src="../script/jquery-ui-1.8.2.custom.min.js" type="text/javascript"></script>
<script>
    $(function () {
        $("#leaderpanel").dialog({ autoOpen: false });
        $('#setLeader').click(function () {
            if ($('input[type="checkbox"]:checked').length > 0) {
                $("#leaderpanel").dialog("open");
            } else {
                alert('请先选择要设置组安全员的公司');
            }
        });
        $('#leaderpanel').parent().appendTo($("form:first"));
    });
</script>
</html>
